SET NOCOUNT ON
SET QUOTED_IDENTIFIER ON
GO

PRINT '---- tblCards'

PRINT '-- Table title'
INSERT tblUFGTableTitles (utt_Tablename, utt_Languagename, utt_Title, utt_Description)
VALUES ('tblCards','Nederlands','Kaarten','Kaartgegevens')

PRINT '-- Column titles'
INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_HomeClubname','Nederlands','Thuisclubnaam','U dient een clubnaam in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_HomeSeason','Nederlands','Thuisseizoen','U dient een seizoen in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_HomeTeamName','Nederlands','Thuisteamnaam','U dient een teamnaam in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_AgainstClubname','Nederlands','Tegenstander clubnaam','U dient een tegenstander clubnaam in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_AgainstSeason','Nederlands','Tegenstanderseizoen','U dient een seizoen in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_AgainstTeamName','Nederlands','Tegenstander Teamnaam','U dient een teamnaam in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_Clubname','Nederlands','Clubnaam','U dient een clubnaam in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_Season','Nederlands','Seizoen','U dient een Seizoen in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_TeamName','Nederlands','Teamnaam','U dient een teamnaam in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_PersonID','Nederlands','Persoonsnummer','U dient een persoonsnummer in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_Card','Nederlands','Kaart','U dient een kaart in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_Time','Nederlands','Tijd','U dient een tijd in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblCards','crd_NrOfSuspension','Nederlands','Schorsing','Aantal wedstrijden voor schorsing.')

PRINT '-- Panels'
UPDATE tblUFGColumns SET ucl_PanelNumber = NULL WHERE ucl_TableName = 'tblcards'
DELETE tblUFGPanelTitles WHERE upt_TableName = 'tblcards'
DELETE tblUFGPanels WHERE upn_TableName = 'tblcards'


UPDATE tblUFGTables 
SET utb_NrOfColumns = 1
WHERE utb_TableName = 'tblcards' 


INSERT INTO dbo.tblUFGPanels (upn_TableName,upn_PanelNumber,upn_SequenceNumber,upn_NrOfColumns,upn_RowSpan)
VALUES ('tblcards',1,1,5,1)
INSERT INTO dbo.tblUFGPanels (upn_TableName,upn_PanelNumber,upn_SequenceNumber,upn_NrOfColumns,upn_RowSpan,upn_ShowConditionTable,upn_ShowConditionColumn,upn_ShowConditionColumnValue,upn_ShowConditionNoMatch)
VALUES ('tblcards',2,2,1,1,'tblcards','crd_Card','Rood','HideAll')


UPDATE tblUFGColumns 
SET ucl_PanelNumber = 1
WHERE ucl_TableName = 'tblcards' 
AND ucl_ColumnName IN (
	'crd_Season',
	'crd_HomeclubName',
	'crd_HomeTeamName',
	'crd_AgainstClubname',
	'crd_AgainstTeamName',
	'crd_TeamName',
	'crd_Clubname',
	'crd_PersonID',
	'crd_Card',
	'crd_Time'
	
	)

UPDATE tblUFGColumns 
SET ucl_PanelNumber = 2
WHERE ucl_TableName = 'tblcards' 
AND ucl_ColumnName IN (
	'crd_NrOfSuspension')



PRINT '-- Column rights'

PRINT '-- Tasks'
INSERT INTO [IMAGine].[dbo].[tblUFGSearchFilters]
           ([usf_SearchFilterName]
           ,[usf_SearchFilterType]
           ,[usf_SearchFilterCondition]
           ,[usf_RoleName]
           ,[usf_UserName]
           ,[usf_TableName]
           ,[usf_IsWork]
           ,[usf_Message]
           ,[usf_Published]
           ,[usf_Category]
           ,[usf_PublishedBlock])
     VALUES
           ('RedCardSuspensions'
           ,'Role'
           ,'crd_NrOfSuspension IS NULL AND crd_Card = ''Rood'''
           ,'Tuchtcommissie Bond'
           ,null
           ,'tblCards'
           ,1
           ,'SF_RedCardSuspensions'
           ,0
           ,null
           ,'NONE')
GO

INSERT dbo.tblUFGMessages (umm_MessageName, umm_LanguageName, umm_Message)
VALUES ('SF_RedCardSuspensions', 'Nederlands', 'Rode kaarten beoordelen')
GO

INSERT tblUFGRowRights
(urr_TableName,urr_RoleName,urr_SQLSelectExpression,urr_SQLInsertExpression,urr_SQLUpdateExpression,urr_SQLDeleteExpression) VALUES 
('tblCards','Scheidsrechterscommissie Club','1=1',
'@UFGUsername IN (SELECT prs_Username FROM tblPersons WHERE prs_ID IN (SELECT mrf_PersonID FROM tblMatchReferees WHERE mrf_HomeClubname = @mpl_HomeClubname AND mrf_HomeSeason = @mpl_HomeSeason AND mrf_HomeTeamName = @mpl_HomeTeamName AND mrf_AgainstClubname = @mpl_AgainstClubname AND mrf_AgainstSeason = @mpl_AgainstSeason AND mrf_AgainstTeamName = @mpl_AgainstTeamName))',
'@UFGUsername IN (SELECT prs_Username FROM tblPersons WHERE prs_ID IN (SELECT mrf_PersonID FROM tblMatchReferees WHERE mrf_HomeClubname = @mpl_HomeClubname AND mrf_HomeSeason = @mpl_HomeSeason AND mrf_HomeTeamName = @mpl_HomeTeamName AND mrf_AgainstClubname = @mpl_AgainstClubname AND mrf_AgainstSeason = @mpl_AgainstSeason AND mrf_AgainstTeamName = @mpl_AgainstTeamName))',
'@UFGUsername IN (SELECT prs_Username FROM tblPersons WHERE prs_ID IN (SELECT mrf_PersonID FROM tblMatchReferees WHERE mrf_HomeClubname = @mpl_HomeClubname AND mrf_HomeSeason = @mpl_HomeSeason AND mrf_HomeTeamName = @mpl_HomeTeamName AND mrf_AgainstClubname = @mpl_AgainstClubname AND mrf_AgainstSeason = @mpl_AgainstSeason AND mrf_AgainstTeamName = @mpl_AgainstTeamName))'
)